package com.io.nio.mappedByteBuffer;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.CharBuffer;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;

public class Demo1 {

	static int length = 0x8FFF;

	public static void main(String[] args) throws IOException {
		MappedByteBuffer out = new RandomAccessFile("nio2.txt", "rw")
				.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, length+1);
		for (int i = 0; i < length / 3; i++) {
			out.put("我".getBytes());
		}
		out.put((byte)'x');
		System.out.println("========");
		for (int i = length / 2; i < length / 2 + 6; i++) {
			System.out.println((char) out.get(i));
		}
	}

}
